#ifndef CALTEXTEDIT_H
#define CALTEXTEDIT_H

#include <QObject>
#include <QTextEdit>
#include <QWidget>
#include <QTextCursor>
#include <QTextFrameFormat>
#include <QTextCharFormat>
#include <QTextFrame>
#include <QTextTable>
#include <QKeyEvent>
#include <QMessageBox>
#include "highlighter.h"

QT_BEGIN_NAMESPACE
class QCompleter;
QT_END_NAMESPACE

class CalTextEdit : public QTextEdit
{
    Q_OBJECT

public:
    CalTextEdit(QWidget *parent = 0);
    bool isLineCommand(QTextBlock textBlock);
    void setCompleter(QCompleter *c);
    QCompleter *completer() const;
    void createNewCommand();
    void moveCursorToEnd();
signals:
    void sendCommand(QString);

protected slots:
    void getResult(QString);
    void insertCompletion(const QString &completion);    
public slots:
    void receiveFunction(QString);
protected:
    int showResult(QString);

private:
    void keyPressEvent (QKeyEvent * event );
    void mouseDoubleClickEvent(QMouseEvent * event );
    void mousePressEvent (QMouseEvent * event );
    void mouseMoveEvent (QMouseEvent * event );
    void mouseReleaseEvent(QMouseEvent * event );
    void focusInEvent(QFocusEvent *e);
    void contextMenuEvent(QContextMenuEvent *event);

    QString textUnderCursor() const;
    QCompleter *c;
    Highlighter *highlighter;

};

#endif // CALTEXTEDIT_H
